package com.sinry.user.controller;

import cn.hutool.core.codec.Base64;
import cn.hutool.core.io.FileUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author linxinlei
 * @project sinry-cloud
 * @description 测试类
 * @date 2022/5/18
 **/
@RestController
public class TestController {

    @GetMapping("/download")
    public String testPolicy() {
        byte[] bytes = FileUtil.readBytes("/Users/sinry/Downloads/客户告知书.pdf");
        String encode = Base64.encode(bytes);
        return """
                <?xml version="1.0" encoding="UTF-8"?>
                <response xmlns:jtltgi="urn:jt:landtrans_guarantee_insurance:schema:trans:2016">
                    <head>
                        <partnerCode>HBDFBT</partnerCode>
                        <transactionCode>107003</transactionCode>
                        <messageId>20140221151414698</messageId>
                        <transactionEffectiveDate>2014-02-21 15:14:14</transactionEffectiveDate>
                        <responseCompleteMessageStatus>
                            <messageStatusCode>000000</messageStatusCode>
                            <messageStatusDescriptionNumber>0</messageStatusDescriptionNumber>
                        </responseCompleteMessageStatus>
                    </head>
                    <body>
                        <entity>
                            <plcNo>AWUHA0117A19EAAA75S5</plcNo>
                            <plcElcStatus>1</plcElcStatus>
                            <elcMsgFlag>0</elcMsgFlag>
                            <elcEmlFlag>0</elcEmlFlag>
                            <elcPDF>
                            %s
                            </elcPDF>
                        </entity>
                    </body>
                </response>
                """.formatted(encode);

    }

    // http://211.160.16.2:18001/bdyzChannel/GBWEndorseServlet
    @PostMapping("/revert")
    public String testPolicyRevert() {
        return """
                <?xml version="1.0" encoding="UTF-8"?><correctResponse><responseHead><sign>79a00bf0-2981-41c5-9707-19e699b4bc15</sign>
                <requestUUID>65100X79a00bf0-2981-41c5-9707-19e699b4bc15</requestUUID>
                </responseHead><responseBody><responseTime>2022-08-10 17:20:02</responseTime>
                <resultFlag>true</resultFlag>
                <resultMessage>批改成功！</resultMessage>
                <InsurancePhone>4008195598</InsurancePhone>
                <downLoadUrl><![CDATA[https://app12.eydpic.com/prePayment/downloadpdfservlet?encryptionData=%7B%22md5%22%3A%224822fbe0b33a9e761478d60a2260f590%22%2C%22encryptionData%22%3A%22ctsLfE1%2F4sTWygfHv69xAcJZKu6O507lG%2FxUQjLvIKbGFeA%2FRUkaq3DkA%2F6t4rcPsvw9rSSqsSXXNETT33SW8FM9BLl5PZxZv6CkErDyxYasStrgGslKuJTF8Elp%2FRFn88YWDLAWQz0H8q3%2FW0rFX%2BzVfM1zdNsFVhTJF7IBEkhagx8IGKAqIBHt36TPK7Mw%22%7D]]></downLoadUrl>
                <InsuranceTime>2022-08-10 00:00:00 至 2023-02-05 23:59:59</InsuranceTime>
                </responseBody></correctResponse>
                """;
    }
}
